/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2024-10-22
 * Time: 20:57
 */
import java.util.Scanner;

public class Main4{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int am = sc.nextInt();
        int an = sc.nextInt();
        double[][] a = new double[am][an];
        for (int i=0;i<am;i++) {
            for (int j=0;j<an;j++) {
                a[i][j] = sc.nextInt();
            }
        }

        int bm = sc.nextInt();
        int bn = sc.nextInt();
        double[][] b = new double[bm][bn];
        for (int i=0;i<bm;i++) {
            for (int j=0;j<bn;j++) {
                b[i][j] = sc.nextInt();
            }
        }

        int p = sc.nextInt();


        Matrix ma = new Matrix(a);
        Matrix mb = new Matrix(b);

        Matrix mc = ma.add(mb);
        if (mc != null) {
            for (int i=0;i<am;i++) {
                for (int j=0;j<an;j++) {
                    if (j != an-1)
                        System.out.printf("%f ", mc.getMatrix()[i][j]);
                    else
                        System.out.printf("%f\n", mc.getMatrix()[i][j]);
                }
            }
        }


        Matrix md = ma.mul(mb);
        if (md != null) {
            for (int i=0;i<md.getMatrix().length;i++) {
                for (int j=0;j<md.getMatrix()[0].length;j++) {
                    if (j != an-1)
                        System.out.printf("%f ", md.getMatrix()[i][j]);
                    else
                        System.out.printf("%f\n", md.getMatrix()[i][j]);
                }
            }
        }

        if (md != null){
            System.out.println(md.getTrace());
            System.out.println(md.isSymmetric());
            System.out.println(md.norm(p));
        }


    }


}
class Matrix {
    private double[][] elements;
    private int rows;
    private int cols;

    // 构造器：根据二维数组初始化矩阵
    public Matrix(double[][] elements) {
        if (elements == null || elements.length == 0 || elements[0].length == 0) {
            throw new IllegalArgumentException("invalid matrix size");
        }
        this.rows = elements.length;
        this.cols = elements[0].length;
        this.elements = new double[rows][cols];
        for (int i = 0; i < rows; i++) {
            if (elements[i].length != cols) {
                throw new IllegalArgumentException("invalid matrix size");
            }
            System.arraycopy(elements[i], 0, this.elements[i], 0, cols);
        }
    }

    // 构造器：初始化n x n的全0方阵
    public Matrix(int n) {
        if (n <= 0) {
            throw new IllegalArgumentException("invalid matrix size");
        }
        this.rows = n;
        this.cols = n;
        this.elements = new double[n][n];
    }

    // 构造器：初始化m x n的全0矩阵
    public Matrix(int m, int n) {
        if (m <= 0 || n <= 0) {
            throw new IllegalArgumentException("invalid matrix size");
        }
        this.rows = m;
        this.cols = n;
        this.elements = new double[m][n];
    }

    // 矩阵加法
    public Matrix add(Matrix newMatrix) {
        if (this.rows != newMatrix.rows || this.cols != newMatrix.cols) {
            System.out.println("invalid matrix add");
            return null;
        }
        Matrix result = new Matrix(this.rows, this.cols);
        for (int i = 0; i < this.rows; i++) {
            for (int j = 0; j < this.cols; j++) {
                result.elements[i][j] = this.elements[i][j] + newMatrix.elements[i][j];
            }
        }
        return result;
    }

    // 矩阵乘法
    public Matrix mul(Matrix newMatrix) {
        if (this.cols != newMatrix.rows) {
            System.out.println("invalid matrix mul");
            return null;
        }
        Matrix result = new Matrix(this.rows, newMatrix.cols);
        for (int i = 0; i < this.rows; i++) {
            for (int j = 0; j < newMatrix.cols; j++) {
                for (int k = 0; k < this.cols; k++) {
                    result.elements[i][j] += this.elements[i][k] * newMatrix.elements[k][j];
                }
            }
        }
        return result;
    }

    // 计算迹
    public double getTrace() {
        if (this.rows != this.cols) {
            System.out.println("invalid matrix trace");
            return Double.NaN;
        }
        double trace = 0;
        for (int i = 0; i < this.rows; i++) {
            trace += this.elements[i][i];
        }
        return trace;
    }

    // 判断是否为对称矩阵
    public boolean isSymmetric() {
        if (this.rows != this.cols) {
            return false;
        }
        for (int i = 0; i < this.rows; i++) {
            for (int j = 0; j < i; j++) {
                if (this.elements[i][j] != this.elements[j][i]) {
                    return false;
                }
            }
        }
        return true;
    }

    // 计算p-范数
    public double norm(double p) {
        if (p <= 0) {
            System.out.println("invalid p value in matrix norm");
            return Double.NaN;
        }
        double sum = 0;
        for (int i = 0; i < this.rows; i++) {
            for (int j = 0; j < this.cols; j++) {
                sum += Math.pow(Math.abs(this.elements[i][j]), p);
            }
        }
        return Math.pow(sum, 1.0 / p);
    }

    // 获取矩阵
    public double[][] getMatrix() {
        return this.elements;
    }
}
